package com.lyr.mumcock;

public class Mother extends Thread{

    private Kitchen kitchen;

    public Mother(Kitchen kitchen) {
        super("妈妈");
        //设置为守护线程，当孩子线程吃饱结束后，该线程自动结束
        this.setDaemon(true);
        this.kitchen = kitchen;
    }
    // 方法：做饭

    public void cock() throws InterruptedException {
        this.kitchen.docock();
    }

    @Override
    public void run() {
        // 孩子吃完进行做饭操作
        while (true) {
            try {
                this.cock();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
